package pers.cj.pdos.controller;


import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.cj.pdos.controller.base.BaseController;
import pers.cj.pdos.controller.entity.ResponseList;
import pers.cj.pdos.entity.Company;
import pers.cj.pdos.service.IGoodsHouseWarnService;
import pers.cj.pdos.utils.Utils;
import pers.cj.pdos.vo.GoodsHouseWarnVo;
import pers.cj.pdos.vo.GoodsVo;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenj
 * @since 2019-11-04
 */
@Controller
@RequestMapping("/goods")
public class GoodsHouseWarnController extends BaseController {
    @Autowired
    IGoodsHouseWarnService goodsHouseWarnService;

    @RequestMapping("goodsHouseWarn")
    public String goodsHouseWarn(Model model, String type) {
        model.addAttribute("type", Utils.genInteger(type));
        return "goods/goodsHouseWarn";
    }

    @ResponseBody
    @RequestMapping("/goodsHouseWarn/listVo")
    public ResponseList listVo(String page,
                                            String limit,
                                            String storeId,
                                            String houseId,
                                            String type,
                                            String typeId,
                                            String search) {
        Company company = getCompany();
        List<GoodsHouseWarnVo> list = goodsHouseWarnService.listVo(company.getId(),
                Utils.genInteger(page),
                Utils.genInteger(limit),
                storeId,
                houseId,
                Utils.genInteger(type),
                typeId,
                Utils.genLikeData(search));
        long total = goodsHouseWarnService.count(company.getId(),
                storeId,
                houseId,
                Utils.genInteger(type),
                typeId,
                Utils.genLikeData(search));
        return ResponseList.success(total,list);
    }
}
